
package pions.view.calendars;

import pions.view.*;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
import pions.controller.Calendars;
import pions.controller.Calendars.CalendarType;

/**
 *
 * 
 */
public class DisplayCalendar extends javax.swing.JPanel {

    private JToggleButton button_auxpanel = null;

    /** Creates new form Calendars */
    public DisplayCalendar() {
        initComponents();

        setAllVisible(false);
    }

    private void setAllVisible(boolean visible){
        setAvailabilityVisible(visible);
        setWorkVisible(visible);
        setSubordinateVisible(visible);
        setDropShiftVisible(visible);
    }

    private void setAvailabilityVisible(boolean visible){
        button_availability_view.setVisible(visible);
        togglebutton_availability_edit.setVisible(visible);
    }

    private void setWorkVisible(boolean visible){
        button_work_view.setVisible(visible);
    }

    private void setSubordinateVisible(boolean visible){
        button_subordinate_view.setVisible(visible);
        togglebutton_subordinate_edit.setVisible(visible);
    }

    private void setDropShiftVisible(boolean visible){
        togglebutton_dropshift_create.setVisible(visible);
    }

    private void setAuxPanel(JPanel panel, JToggleButton button){
        if(button_auxpanel != null) button_auxpanel.setSelected(false);
        button_auxpanel = button;

        PIONSView.getInstance().setAux(panel);
    }

    private void resetAuxPanel(){
        if(button_auxpanel != null) button_auxpanel.setSelected(false);
        PIONSView.getInstance().setAux(new IdleScreen());
        button_auxpanel = null;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        label_title = new javax.swing.JLabel();
        label_directions = new javax.swing.JLabel();
        button_work_view = new javax.swing.JButton();
        button_availability_view = new javax.swing.JButton();
        button_subordinate_view = new javax.swing.JButton();
        button_work = new javax.swing.JRadioButton();
        button_availability = new javax.swing.JRadioButton();
        button_subordinate = new javax.swing.JRadioButton();
        button_dropshift = new javax.swing.JRadioButton();
        togglebutton_availability_edit = new javax.swing.JToggleButton();
        togglebutton_dropshift_create = new javax.swing.JToggleButton();
        togglebutton_subordinate_edit = new javax.swing.JToggleButton();
        button_activate = new javax.swing.JButton();
        label_directions_activate = new javax.swing.JLabel();

        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(300, 400));

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(pions.PIONS.class).getContext().getResourceMap(DisplayCalendar.class);
        label_title.setFont(resourceMap.getFont("label_title.font")); // NOI18N
        label_title.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_title.setText(resourceMap.getString("label_title.text")); // NOI18N
        label_title.setName("label_title"); // NOI18N

        label_directions.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_directions.setText(resourceMap.getString("label_directions.text")); // NOI18N
        label_directions.setName("label_directions"); // NOI18N

        button_work_view.setText(resourceMap.getString("button_work_view.text")); // NOI18N
        button_work_view.setName("button_work_view"); // NOI18N
        button_work_view.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_work_viewActionPerformed(evt);
            }
        });

        button_availability_view.setText(resourceMap.getString("button_availability_view.text")); // NOI18N
        button_availability_view.setName("button_availability_view"); // NOI18N
        button_availability_view.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_availability_viewActionPerformed(evt);
            }
        });

        button_subordinate_view.setText(resourceMap.getString("button_subordinate_view.text")); // NOI18N
        button_subordinate_view.setName("button_subordinate_view"); // NOI18N
        button_subordinate_view.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_subordinate_viewActionPerformed(evt);
            }
        });

        button_work.setFont(resourceMap.getFont("jRadioButton3.font")); // NOI18N
        button_work.setText(resourceMap.getString("button_work.text")); // NOI18N
        button_work.setName("button_work"); // NOI18N
        button_work.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_workActionPerformed(evt);
            }
        });

        button_availability.setFont(resourceMap.getFont("jRadioButton3.font")); // NOI18N
        button_availability.setText(resourceMap.getString("button_availability.text")); // NOI18N
        button_availability.setName("button_availability"); // NOI18N
        button_availability.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_availabilityActionPerformed(evt);
            }
        });

        button_subordinate.setFont(resourceMap.getFont("jRadioButton3.font")); // NOI18N
        button_subordinate.setText(resourceMap.getString("button_subordinate.text")); // NOI18N
        button_subordinate.setName("button_subordinate"); // NOI18N
        button_subordinate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_subordinateActionPerformed(evt);
            }
        });

        button_dropshift.setFont(resourceMap.getFont("jRadioButton3.font")); // NOI18N
        button_dropshift.setText(resourceMap.getString("button_dropshift.text")); // NOI18N
        button_dropshift.setName("button_dropshift"); // NOI18N
        button_dropshift.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_dropshiftActionPerformed(evt);
            }
        });

        togglebutton_availability_edit.setText(resourceMap.getString("togglebutton_availability_edit.text")); // NOI18N
        togglebutton_availability_edit.setName("togglebutton_availability_edit"); // NOI18N
        togglebutton_availability_edit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                togglebutton_availability_editActionPerformed(evt);
            }
        });

        togglebutton_dropshift_create.setText(resourceMap.getString("togglebutton_dropshift_create.text")); // NOI18N
        togglebutton_dropshift_create.setName("togglebutton_dropshift_create"); // NOI18N
        togglebutton_dropshift_create.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                togglebutton_dropshift_createActionPerformed(evt);
            }
        });

        togglebutton_subordinate_edit.setText(resourceMap.getString("togglebutton_subordinate_edit.text")); // NOI18N
        togglebutton_subordinate_edit.setName("togglebutton_subordinate_edit"); // NOI18N
        togglebutton_subordinate_edit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                togglebutton_subordinate_editActionPerformed(evt);
            }
        });

        button_activate.setText(resourceMap.getString("button_activate.text")); // NOI18N
        button_activate.setName("button_activate"); // NOI18N
        button_activate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_activateActionPerformed(evt);
            }
        });

        label_directions_activate.setText(resourceMap.getString("label_directions_activate.text")); // NOI18N
        label_directions_activate.setName("label_directions_activate"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(label_title, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
            .addComponent(label_directions, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(button_subordinate_view)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(togglebutton_subordinate_edit))
                    .addComponent(button_subordinate))
                .addContainerGap(87, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(button_work_view))
                    .addComponent(button_work))
                .addContainerGap(151, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(button_availability_view)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(togglebutton_availability_edit))
                    .addComponent(button_availability))
                .addContainerGap(157, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(21, 21, 21)
                        .addComponent(togglebutton_dropshift_create))
                    .addComponent(button_dropshift))
                .addContainerGap(189, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(label_directions_activate)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(button_activate, javax.swing.GroupLayout.DEFAULT_SIZE, 142, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(label_title)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(label_directions)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(button_availability, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(button_availability_view)
                    .addComponent(togglebutton_availability_edit))
                .addGap(7, 7, 7)
                .addComponent(button_work, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(button_work_view)
                .addGap(7, 7, 7)
                .addComponent(button_subordinate)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(button_subordinate_view)
                    .addComponent(togglebutton_subordinate_edit))
                .addGap(7, 7, 7)
                .addComponent(button_dropshift)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(togglebutton_dropshift_create)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(button_activate)
                    .addComponent(label_directions_activate))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void button_work_viewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_work_viewActionPerformed
        PIONSView.openLink(this, Calendars.getReadLink(CalendarType.WorkSchedule));
    }//GEN-LAST:event_button_work_viewActionPerformed

    private void button_availability_viewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_availability_viewActionPerformed
        PIONSView.openLink(this, Calendars.getReadLink(CalendarType.Availability));
    }//GEN-LAST:event_button_availability_viewActionPerformed

    private void button_subordinate_viewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_subordinate_viewActionPerformed
        PIONSView.openLink(this, Calendars.getReadLink(CalendarType.SubordinateSchedule));
    }//GEN-LAST:event_button_subordinate_viewActionPerformed

    private void button_availabilityActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_availabilityActionPerformed
        setAvailabilityVisible(button_availability.isSelected());
    }//GEN-LAST:event_button_availabilityActionPerformed

    private void button_workActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_workActionPerformed
        setWorkVisible(button_work.isSelected());
    }//GEN-LAST:event_button_workActionPerformed

    private void button_subordinateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_subordinateActionPerformed
        setSubordinateVisible(button_subordinate.isSelected());
    }//GEN-LAST:event_button_subordinateActionPerformed

    private void button_dropshiftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_dropshiftActionPerformed
        setDropShiftVisible(button_dropshift.isSelected());
    }//GEN-LAST:event_button_dropshiftActionPerformed

    private void togglebutton_availability_editActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_togglebutton_availability_editActionPerformed
        if(togglebutton_availability_edit.isSelected()){
            setAuxPanel(new Availability(), togglebutton_availability_edit);
        }
        else {
            resetAuxPanel();
        }
    }//GEN-LAST:event_togglebutton_availability_editActionPerformed

    private void togglebutton_subordinate_editActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_togglebutton_subordinate_editActionPerformed
        if(togglebutton_subordinate_edit.isSelected()){
            setAuxPanel(new Schedule(), togglebutton_subordinate_edit);
        }
        else {
            resetAuxPanel();
        }
    }//GEN-LAST:event_togglebutton_subordinate_editActionPerformed

    private void togglebutton_dropshift_createActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_togglebutton_dropshift_createActionPerformed
        if(togglebutton_dropshift_create.isSelected()){
            setAuxPanel(new DropShift(), togglebutton_dropshift_create);
        }
        else {
            resetAuxPanel();
        }
    }//GEN-LAST:event_togglebutton_dropshift_createActionPerformed

    private void button_activateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_activateActionPerformed
        PIONSView.openLink(this, "http://www.google.com/calendar/");
    }//GEN-LAST:event_button_activateActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton button_activate;
    private javax.swing.JRadioButton button_availability;
    private javax.swing.JButton button_availability_view;
    private javax.swing.JRadioButton button_dropshift;
    private javax.swing.JRadioButton button_subordinate;
    private javax.swing.JButton button_subordinate_view;
    private javax.swing.JRadioButton button_work;
    private javax.swing.JButton button_work_view;
    private javax.swing.JLabel label_directions;
    private javax.swing.JLabel label_directions_activate;
    private javax.swing.JLabel label_title;
    private javax.swing.JToggleButton togglebutton_availability_edit;
    private javax.swing.JToggleButton togglebutton_dropshift_create;
    private javax.swing.JToggleButton togglebutton_subordinate_edit;
    // End of variables declaration//GEN-END:variables

}
